This invention relates to a method of procedures linkage control which changes over the effective ranges of variables in the procedures of a program in accordance with procedure call methods.
A conventional procedure call system involves the problem that the effective range of variables used in one procedure can not be changed when other procedures are called by the declaration of called procedures or by the declaration of the variables in the procedures on the basis of the specification of a program language describing the procedures.
The effective ranges of variables of a conventional program language will be described with reference to a well known program language, PASCAL, by way of example.
The effective ranges of the variables in PASCAL will be explained with reference to FIG. 1. PASCAL itself is described in detail in ISO/DP 7185-Specification for the computer programming language PASCAL. In the drawing, reference numeral 100 represents a program as a whole. Reference numerals 110 and 120 represent a main program SCOPE and a procedure P, respectively. In the main program 120, variables a, b and c represented by 121, 112 and 113 are declared. In the procedure 120, variables a and b represented by 121 and 122 are declared. Reference numeral 123 represents a procedure call statement. To use the variables a and b in procedure 120 means the use of the variables declared at 121 and 122, but does not mean the use of the variables declared at 111 and 112. To use the variables declared at 121 and 122 in the procedure 120 when the variables a and b are used in the procedure 120 means that the variables a and b are "local" in the procedure 120. To use the variable c 123, which is not declared in the procedure 120, means that this variable c is "global" for the procedure 120.
The effective ranges of the variables a, b and c used in the program 100 are shown at 101. The effective ranges of the variables a, b and c declared at 111, 112 and 113 of the main program 100 are shown at 114, 115 and 116, respectively. The reason why the portions corresponding to the procedure 120 are represented by dotted lines in the ranges of 114, 115 and 116 is that the dotted portions are not effective. The effective ranges of the variables a and b declared at 112 and 121 of the procedure 120 are shown at 124 and 125. The effective ranges of 124 and 125 correspond to the range of the procedure 120, and are the same as the dotted portions 116 and 117 of the ranges 114 and 115.
As described above, whether a given variable is local or global is determined by the declaration of variables in PASCAL. Unless the declaration of the variables in the procedure is changed, the variables in the procedure can not be "localized" or "globalized".
Next, the effective ranges of variables in BASIC will be described with reference to FIG. 2. BASIC is described in detail in "HITAC Manual VOS2/VOS3 BASIC Language" (8080-3-256; Hitachi, Ltd.). In the drawing, reference numeral 130 represents a program as a whole, and reference numerals 140 and 150 represent a main program and a procedure, respectively. The delivery of arguments can not be made in a GOSUB statement which calls a procedure, and declaration of a local variable can not be made, either, on the procedure side. This means that all the variables in the procedure are dealt with as global variables. The effective ranges of variables A, B and C used for instructions 141, 142 and 143 in the main program 140 are shown at 145, 146 and 147 in 131, respectively. In BASIC, the variables in the procedure called by GOSUB can not be localized in the procedure.
As described above, the effective ranges of the variables can not be changed in accordance with the procedure call methods in PASCAL and BASIC, so that the following problems develop.
(1) Procedures must be changed to change the effective ranges of variables in the procedures. When it is desired to use, in the main program 110, the value of the variable 122 in the procedure 120 for example, the number of arguments in the declaration statement 121 of the procedure 120 must be increased, or the declaration of the variable 122 must be released in the procedure 120.
(2) If the correction described in item (1) is made in one procedure call when a procedure is called from a plurality of locations, the rest of the procedure calls must also be corrected.
For example, if the number of arguments is increased in the declaration statement 121, the arguments must also be designated in all the procedure call statements. If the declaration of a variable in one procedure is released, the variable must be fixed at the call portion and a value must be given to it.